home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d13 / ptv2n1.arc / FILESIDE.ASC < prev    next >
Text File  |  1991-03-26  |  2KB  |  46 lines

  1. NOTES ON THE LISTINGS FILES FOR "TYPING YOUR DATA":
  2.  
  3. The download files for this article include two complete sets of
  4. files.  The first are those discussed in the text: TYPES.H,
  5. TYPES.CPP, and TYPEDEMO.CPP.  These files implement a simple
  6. database from three data types.  A second set of files is
  7. provided that were too long to include in the text.  These allow
  8. for strings plus the five major numeric types from int to long
  9. double.  The code for typed values gets long fast as you add
  10. types -- it tends to increase by the square of the types.  That's
  11. because each class has to support operations with each of the
  12. other classes.  The code doesn't really get more complex, just a
  13. lot longer.
  14.  
  15. When you do something like this, it's best to start with two or
  16. maybe three data types to get all the basics sorted out.  Then
  17. you can take advantage of the strong symmetry in the code to add
  18. the additional types using your debugged code as a model.  This
  19. is especially important since the floating point types add other
  20. problems that aren't really germane to the basic algorithm.  For
  21. example, a double can be too small as well too large to convert
  22. into a float.  That is, it can be a value too close to zero.
  23.  
  24. That's moderately interesting, and you can see how to deal with
  25. it in TYPESALL.CPP, but it doesn't really have anything to do
  26. with the basic objective of creating typed data objects.  It's
  27. best to defer such questions until you have your basic set of
  28. methods worked out.  The files with all of the numeric types
  29. represented are TYPESALL.H and TYPESALL.CPP.  This version of the
  30. value objects works with the original demo program just as well,
  31. since that's the point of encapsulation.  But TYPEDEMO.CPP
  32. doesn't include functions to assert the extra types, so I wrote a
  33. second demo program, TYPEDEM2.CPP, to show off the expanded
  34. definition of types.
  35.  
  36. To compile the examples, put TYPES.H and TYPESALL.H in your
  37. include directory.  Create one project with TYPES.CPP and
  38. TYPEDEMO.CPP, and another project with TYPESALL.CPP and
  39. TYPEDEM2.CPP.  To use typed data objects in your own projects,
  40. just add TYPESALL.CPP to your own project and include
  41. <TYPESALL.H> in your source code.  For simplicity, delete the
  42. reduced version files used in the article, and then rename the
  43. full version files as TYPES.H and TYPES.CPP.
  44.  
  45.                               --Gary W. Sims
  46.